package com.xp.agent.common;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import com.xp.agent.dto.AlarmMessage;

public class MessageQueue {

	private BlockingQueue<AlarmMessage> queue = new LinkedBlockingQueue<>();
	private static MessageQueue instance = new MessageQueue();

	private MessageQueue() {
	}

	public static MessageQueue getInstance() {
		return instance;
	}

	public void put(AlarmMessage message) {
		try {
			queue.put(message);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	public AlarmMessage poll() {
		try {
			return queue.take();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		return null;
	}
}
